package org.edu.modules.act.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.edu.common.api.vo.Result;
import org.edu.modules.act.common.result.ActionResult;
import org.edu.modules.act.common.result.ResultBuilder;
import org.edu.modules.act.service.DeploymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 部署信息的控制层
 *
 * @版权所有 福州土著人信息科技有限公司
 */

@Api(tags="流程上线模块")
@RestController
@RequestMapping("/activiti/deployment")
@Slf4j
public class DeploymentController {

	@Autowired
	private DeploymentService deploymentService;

	/**
	 * 查询已部署的模型分页
	 *
	 * @param current    当前页数
	 * @param pageSize       每页记录数
	 * @param deploymentName 已部署的模型名称
	 * @return
	 */
	@ApiOperation(value="流程查询", notes="流程上线模块-流程查询")
	@GetMapping(path = "/queryDeployment")
	public Result<?> queryDeployment(Integer current,Integer pageSize,String deploymentName) {
		Map<String, Object> data = deploymentService.queryDeployment(current, pageSize, deploymentName);
		return Result.OK(data);
	}

	/**
	 * 删除已部署的模型
	 *
	 * @param deploymentId 部署ID
	 * @return
	 */
	@ApiOperation(value="下线查询", notes="流程上线模块-流程下线")
	@PostMapping(path = "/deleteDeployment")
	public ActionResult deleteDeployment(String deploymentId) {
		deploymentService.deleteDeployment(deploymentId);
		return ResultBuilder.buildActionSuccess();
	}

}
